//设置session参数
function setSessionfunc(typeid,zid,tankuang,danweiID){
	//alert("typeid = "+typeid+" zid = "+zid+" tankuang ="+tankuang+" danweiID ="+danweiID);
	// 设置当前用户的session值
    // typeid 系统分类id (比如对应前端八大类), zid 当前用户的站点id
	var url="/bigscrenn/setUserSession?typeid="+typeid+"&zid="+zid+"&cid="+tankuang+"&cid1="+danweiID;
    console.log(url,"session参数");
	$.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     async: false,				   
	     success: function(data){
              console.log(data,'参数');         
	     }
    		
    });	
};
$(function(){
	
	//地图切换开始
	$("#exchangeMap").click(function(){
		
		var index = layer.load(1, {   //iframe中地图加载完成走之前显示loading动画
		  shade: [0.1,'#fff']         //0.1透明度的白色背景
		});
		var $iFrame = $("#gdMap");
		$iFrame.prop("src", "./gaodeMap.html");
		$iFrame.load(function() {
			//alert("加载完毕");
			layer.close(index);      //iframe中地图加载完成走之后  关闭loading动画
		});
		$("#gaodeMapID").css("display","block");
		$("#closeGaodeBtn").css("display","block");
	})
	$("#closeGaodeBtn").click(function(){
		$("#gdMap").attr('src','');
		$(this).css("display","none");
		$("#gaodeMapID").css("display","none");
	})
	//地图切换結束
	
})

var yn_anquan = 0, //安全运行天数
	yn_jkzs = 0,   //健康指数
	yn_sbfl = 0,   //设备分类
	yn_bynhzb=0,   //本月能耗占比
	yn_bynhb=0,    //本月能耗比
	yn_fhrl = 0,   //负荷容量
	yn_glys = 0,   //功率因素
	yn_gjxx = 0,   //告警信息
	yn_gjtj = 0,   //告警统计
	yn_online = 0; //值班人员




//new add 2019-03-27
var myVm;
var yonghuID,dwID,dw1Name,dw2Name,dw1ID;
var userid = "";
var unitID = "";
var userType="";
var zid ="",zid1='';    // 站点id
var danweiID='';//单位id
var danweiName='';//上页选中来的单位名称
var unitName='';//登录的单位名称
a();
function a(){
	var url="/bigscrenn/getUserSession";
	var defer = $.Deferred();
	 $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     //async: false,				   
	     success: function(data){
	    	 defer.resolve(data);
		 console.log("session数据="+data);
		 // js解析json串
	     var obj={};
	     if(data&&data!=null&&data!=undefined&&data!=''){
	    	obj = JSON.parse(data);
	     }
	     if (obj.session.length>0){
	           /*
				 * alert(obj.session[0].UserID);//用户id
				 * alert(obj.session[0].Name);//用户名称
				 * alert(obj.session[0].UnitID);//用户单位id
				 * alert(obj.session[0].UnitName);//用户单位名称
				 * alert(obj.session[0].UserAuthority);//用户权限 2
				 * 所有单位 3 本单位
				 * alert(obj.session[0].typeid);//系统分类id
				 * (比如对应前端八大类)
				 * alert(obj.session[0].zid);//当前用户的站点id
				 * alert(obj.session[0].cid1);//自定义id1(单位id)
				 */	
	    	   dw1ID = obj.session[0].UnitID;
	    	   yonghuID = obj.session[0].UserID;
			   dwID = (obj.session[0].cid1).split(",")[0];  //单位id方法
			   
			   userid = obj.session[0].UserID;
  			   unitID = obj.session[0].UnitID;
  			   userType = obj.session[0].UserAuthority;
  			   //alert("userType = "+userType);
  			   
  			   console.log("我是三级站点id="+zid);
  			   danweiID = (obj.session[0].cid1).split(",")[0];  //单位id方法
  			   
  			   danweiName = (obj.session[0].cid1).split(",")[1];//上页选中来的单位名称
  			   unitName = obj.session[0].UnitName;              //登录来的单位名称
  			   
  			   zid = (obj.session[0].zid).split(",")[0];  //站点id
  			   if(zid=='undefined'){
  				 zid= obj.session[0].zid;
  			   }
  			   zName = (obj.session[0].zid).split(",")[1];//上页选中来的站点名称
			   
			   if(dwID=='' || dwID=='undefined'){
				   dwID = dw1ID;
			   }
			   
			   if(danweiID==''|| danweiID==null|| danweiID =='undefined'){
               	  danweiID = unitID
               }
			   //alert("danweiName i ="+danweiName);
               if(danweiName==''||danweiName==null || danweiName==undefined){
               	  danweiName = unitName;
               }
               //alert("danweiName i ="+danweiName);
			   //alert("我是三级用户id ="+yonghuID + " 和单位 = " +dwID);
               $("#unitTitle>span").text(danweiName);
	    	 }
		    	
		    	
		    	upLoadFunc(zid);                // 下载方法
		    	zhanDianNumFunc();              //站点列表方法
		    	getPicData();
	     }
	});
	 return defer.promise();
}

function a1(){
	jiankang(dwID,yonghuID); //健康指数方法
    gonglvys(dwID,yonghuID);        //功率因数方法
    monthNengHao(dwID,yonghuID);    //本月能耗方法
    safeDays(yonghuID,dwID);          //安全运行天数
    yxfxFunc(dwID);                 //告警信息方法
}
//负荷容量 专用
function furlFuc(){
   //alert(dwID+"---11---"+yonghuID);
	resetFuheFunc(dwID,yonghuID);       // （新）负荷容量方法
    shebeiFunc(dwID,yonghuID);        //设备分类方法
	haonengZBFunc(dwID,yonghuID);     //能耗分类占比方法
	gaojing(dwID,yonghuID);           //告警信息方法
}
//new add 2019-03-27

function zhanDianNumFunc(){
	//alert(userType+"----"+userid+'-----'+unitID+'---'+danweiID);
	// 具体用户进来的操作
    if(userType==3){
    	
    	//alert("我的身份是具体用户 userType ="+userType);
    	$(".backHome-box >a").css("display","none");// “返回首页”隐藏
    }else{
    	//alert("我的身份是具体用户 userType = "+userType);
    }
	//var url="/bigtongji/getUnitIDList?unitid="+unitid;//吴新接口
	var url="/bigscrenn/getSiteList?userid="+userid+"&unitid="+danweiID;
	//alert("进来的单位下的站点数地址="+url);
	var defer = $.Deferred();
	 $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     //async: false,				   
	     success: function(data){
	    	 defer.resolve(data);
               //alert(data);
               console.log(data);
               var dataObj=eval("("+data+")");//转换为json对象 
               //alert(dataObj);
               //alert(dataObj);
             	var total= dataObj.total;
             	var zhanDianNum = total;
             	if(total==0){
             		//console.log("点击的单位下的站点数："+total);
             		layer.msg('这个单位没有站点');
             	}
             	if(total==1){
             		//console.log("点击的单位下的站点数："+total);
             		//setSessionfunc('','','',unitid);
             		window.location.href = "specificUser.html"
             	}
             	//alert("total="+total);
             	onlineFunc(dataObj.rows[0].CID);
         	    console.log(JSON.stringify(dataObj),"站点====");
         	    if($("#dl dd").length>0){
         	    	$("#dl").empty();
         	    }
                for (var i = 0; i < dataObj.rows.length; i++) {
         		  var name= dataObj.rows[i].UNITNAME;
         		  var CID= dataObj.rows[i].CID;
         		  //alert(name);
         		  $("#dl").append('<dd><a class="zhanDian" cid='+CID+' href="specificUser.html">'+name+'</a></dd>')
         	    }
                
        	    layui.use('element', function() {
					var element = layui.element; // 导航的hover效果、二级菜单等功能，需要依赖element模块
					// 监听导航点击
					element.on('nav(demo)', function(elem) {
						// console.log(elem)
						// alert(elem.text());
						 //alert($(this).attr('cid'));
						
						//alert("点击当前站点对应的d.zid="+$(this).attr('cid'));
	                	//alert("zid="+$(this).attr('cid')+"vs.danweiID="+vm_zd.danweiID);
						var codestr = encodeURI(elem.text());// 编码，适应ie浏览器识别中文问题
						var dw_codestr = encodeURI(danweiName);
	                	setSessionfunc('',$(this).attr('cid')+','+codestr,'',(danweiID+','+dw_codestr));     // session存站点（第二个参）
	                	
	                	//返回上一级跳转逻辑处理
						var obj = {'yiji':'1','erji':'2','sanji':'3'};
	                	//var obj = {'sanji':'3'};
			            var objStr = JSON.stringify(obj);
			            localStorage.setItem("urls",objStr);
	                	
					});
				});
	     }
	});
	 return defer.promise();
}
//站点结束
//电气图开始
function getPicData(){
	//alert("电气图 中danweiID = "+danweiID);
	// fid单位id或站点id
    var url="/bigscrenn/getVlabelList?fid="+danweiID;//这里的id是单位id
    //alert("电气图接口="+url);
    var defer = $.Deferred();
	 $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     //async: false,				   
	     success: function(data){
	    	 defer.resolve(data);
	    	 console.log("电气图数据==:"+data);
	    	 //specificMapFunc(); //地图方法  此方法再可视化地图中
	    	 // js解析json串
	    	 var obj = JSON.parse(data);
	    	                            //绑定单位电气图数量
	    	 if($("#ditu").siblings().length>0){
	    		 $("#ditu").siblings(".dq").remove();
	    	 }
	    	 for(var i=0;i<obj.rows.length;i++){
	    		$("#iscrollUL").append('<li class="dq" style="cursor: pointer;">'+obj.rows[i].VNAME+'</li>') 
	    	 }
	    	 //点击操作
	    	 console.log("li === " + $("#tabDiv li").length);
			 $("#tabDiv li").first().addClass("elc-BtnAct"); // 默认第一个大用户展开
			 
			 $("#tabDiv li").click(function(){               // 点击电气图按钮事件操作
				$(this).addClass("elc-BtnAct");                 // 点击当前添加类elc-BtnAct
				$(this).siblings().removeClass("elc-BtnAct");   // 点击当前的兄弟节点移除类elc-BtnAct
				var index = $("#tabDiv li").index(this);
				//alert($(this).text()+" id = "+index);
				if(index==0){
              	     //alert("地图");
	              	 $("#scrollBox").css("display","none");
	      		     $("#spHomeMap").css("display","block");
	      		     $("#fullScreen").css("display","none");
                }
				if(index > 0){
					    //alert("$('#iframeBox iframe').length = "+$('#iframeBox iframe').length);
						if($('#iframeBox iframe').length>0){
							 $('#iframeBox').empty();
						 }
					   //alert("===="+index);
	            	   $("#scrollBox").css("display","block");
		      		   $("#spHomeMap").css("display","none");
		      		   $("#fullScreen").css("display","block");
		      		   
		      		   // js解析json串
		                var obj = JSON.parse(data);
		                // alert("记录数="+obj.total);//记录数
		                var toOtherURL = "";
		                var str = '/vlabel/actionshow?type=1&fid='+danweiID+'&id='+obj.rows[(index-1)].CID+'&bl=0.60&name='+obj.rows[(index-1)].VNAME;
						var ecURL = encodeURI(encodeURI(str));// 二次编码，适应ie浏览器识别中文问题
						//alert("str"+(i+1)+"==:"+str);
						var urlStr = ecURL;
						// 本地存储电气图地址和名称
						toOtherURL = '/vlabel/actionshow?type=1&fid='+danweiID+'&id='+obj.rows[(index-1)].CID+'&bl=&name='+obj.rows[(index-1)].VNAME;// 到其他页面不要传参bl
						localStorage.setItem("urlStr", toOtherURL);
						localStorage.setItem("picName", obj.rows[(index-1)].VNAME);
						//alert("电气图地址url="+str);
						
						$('#iframeBox').append('<iframe width="1920px" height="1080px"  id="iframe" src='+str+'  style="background: #000000;"></iframe>')
                }
				/*// js解析json串
                var obj = JSON.parse(data);
                alert("记录数="+obj.total);//记录数
                for (var i=0;i<obj.rows.length;i++){
                      // alert(obj.rows[i].CID);//电气图id
                      // alert(obj.rows[i].VNAME);//电气图名称
                }*/
                
				
			 })
           
	     }
     });
	 return defer.promise();
}

function picFunc(){
	
}
//电气图结束

/*能耗占比分类方法  开始*/
// 得到指定站点本月能耗分类统计
// 得到单位下所有站点本月能耗分类统计 unitid 单位ID，userid 用户ID
//haonengZBFunc();
function haonengZBFunc(unitid,userid){
	 //var url="/bigtongji/getMonthLHList?unitid=010000000000&userid=000000000001";
	 var url="/bigtongji/getMonthLHList?unitid="+unitid+"&userid="+userid;
	 var defer = $.Deferred();
	 $.ajax({
	        cache: true,
	        type: "POST",
	        url:url,
	        data:"",
	        //async: false,
	        success: function(data) {
	        	defer.resolve(data);
	           var dataArr = [];
	           //alert("本月能耗分类 = "+data);
	           console.log(data);
	           var dataObj=eval("("+data+")");// 转换为json对象
	           // alert(dataObj);
	           //alert(dataObj);
	           for (var i = 0; i < dataObj.rows.length; i++) {// id
	             	//var name= dataObj.rows[i].NAME;// 名字
	             	//var value= dataObj.rows[i].VALUE;
	             	//alert(value);
	        	   dataArr.push({"name":dataObj.rows[i].NAME+dataObj.rows[i].VALUE,"value":dataObj.rows[i].VALUE})
	          }
	           zhuz(dataArr);
	           yn_bynhzb=1;
	       }
	
	 });
	 return defer.promise();
}

function zhuz(dataArr) {
	console.log("dataArr="+JSON.stringify(dataArr))
	var enegConsumptChart = echarts.init(document.getElementById("month_nenghaozhanbi"));
	var enegConsumpt_option = {
		title: {
			text: '本月能耗占比',
			show:false,
			x: 'center',
			y:'3%',
			textStyle: {
				// 文字颜色
				color: '#fff',
				// 字体风格,'normal','italic','oblique'
				fontStyle: 'normal',
				// 字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 |
				// 400...
				fontWeight: '100',
				// 字体系列
				fontFamily: 'sans-serif',
				// 字体大小
				　　　　fontSize: 18
			}
		},
		tooltip: {
			trigger: 'item',
			formatter: "{a} <br/>{b} :<br/> {c} ({d}%)"
		},
		legend: {
			type: 'scroll',  			    //分页类型
			pageIconColor: '#6495ed',       //翻页下一页的三角按钮颜色
			pageIconInactiveColor: '#aaa',  //翻页（即翻页到头时）
			pageIconSize: 11,               //翻页按钮大小
			pageFormatter: '',				//隐藏翻页的数字
			pageButtonItemGap: -6,			//翻页按钮的两个之间的间距
			
			show:true,
			orient: 'vertical',// 'horizontal'
			left: '5%',
			y: '20%',
			itemGap: 10,
			/* data: ['x座机房', 'x层厂房', '办公室', '照明'], */
			data: dataArr,
			textStyle: {
				// 文字颜色
				color: '#fff',
				// 字体风格,'normal','italic','oblique'
				fontStyle: 'normal',
				// 字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 |
				// 400...
				fontWeight: '100',
				// 字体系列
				fontFamily: 'sans-serif',
				// 字体大小
				fontSize: 14
			}
		},
		series: [{
			name: '能耗占比分类',
			type: 'pie',
			radius: '50%',
			center: ['85%', '50%'],
			data: dataArr,
			label:{
				normal:{
					show:false,
					formatter: '{c} ({d}%)',// //饼图边的脚数据
				}
			},
			itemStyle: {
				normal: {
					color: function(params) {
						// 自定义饼图颜色
						var colorList = [
							'#08b0c9' , '#0FEB8B',  '#DE67F4',  '#21E0DA',
							'#21E0DA', '#33B565',
						];
						return colorList[params.dataIndex]
					}
				}

			}
		}]
	};
	enegConsumptChart.setOption(enegConsumpt_option);
	$(document).ready(function() {
		enegConsumptChart.resize();
	});
	window.addEventListener("resize", function() {
		enegConsumptChart.resize();
	})
}
/*能耗占比分类方法  结束*/

/*功率因素方法开始*/
//得到多个站点的实时功率因素   unitid 单位ID，userid 用户ID
function gonglvys(unitid,userid){
	var gonglvArr = [];var gonglvArr1 = [],gonglvArr2=[];
	 //得到多个站点的实时功率因素   unitid 单位ID，userid 用户ID
	 var url="/bigtongji/getGlysValue?unitid="+unitid+"&userid="+userid;   
	 var defer = $.Deferred();
	 $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     //async: false,				   
	     success: function(data){
	    	 defer.resolve(data);
              //alert("功率因素 = "+data);
              console.log(data,"功率因素");
              var dataObj=eval("("+data+")");//转换为json对象 
              //alert(dataObj);
              //alert(dataObj);
         	  console.log(JSON.stringify(dataObj),"功率因素");
              for (var i = 0; i < dataObj.rows.length; i++) {
         		var name= dataObj.rows[i].UNITNAME;
         		var value= dataObj.rows[i].VALUE;
         		
         		gonglvArr.push({"name":name,"value":value});
         		gonglvArr1.push(name);
         		gonglvArr2.push(value);
         	  }
	 			
		    //alert("gonglvArr = "+gonglvArr1.length);
		    var ulHtml = $("#glUl li");
		    //alert("ulHtml = "+ulHtml.length);
		    if(ulHtml.length>0){ //判断是否为空 ，防止刷新是不断累加
				$("#glUl").empty();
			}
			for (var i = 0; i < gonglvArr.length; i++) {
				
				$("#glUl").append('<li>'+gonglvArr1[i]+' : <span class="glValue">'+gonglvArr2[i]+'</span></li>');
			}
             console.log(JSON.stringify(gonglvArr)+"gonglvArr==");
            //gonglvShow(gonglvArr);
             yn_glys = 1;
	     }
	 });
	 return defer.promise();
}
//功率因素图表
function gonglvShow(gonglvArr){
	
	//var gongLvChart = echarts.init(document.getElementById("user-gonglv"));
	var gongLv_option = {
		title: {
			text: '功率因素',
			show:false,
			x: 'center',
			textStyle: {
				// 文字颜色
				color: '#fff',
				// 字体风格,'normal','italic','oblique'
				fontStyle: 'normal',
				// 字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 |
				// 400...
				fontWeight: '100',
				// 字体系列
				fontFamily: 'sans-serif',
				// 字体大小
				fontSize: 18
			}
		},
		tooltip: {
			trigger: 'item',
			formatter: "{a} <br/>{b} : {c} ({d}%)"
		},
		legend: {
			show:false,
			orient: 'horizontal',// 'vertical'
			left: 'center',
			y: 'bottom',
			itemGap: 10,
			/* data: ['x座机房', 'x层厂房', '办公室', '照明'], */
			data: gonglvArr,
			textStyle: {
				// 文字颜色
				color: '#fff',
				// 字体风格,'normal','italic','oblique'
				fontStyle: 'normal',
				// 字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 |
				// 400...
				fontWeight: '100',
				// 字体系列
				fontFamily: 'sans-serif',
				// 字体大小
				　　　　fontSize: 14
			}
		},
		series: [{
			name: '功率因素',
			type: 'pie',
			radius: ["30%","60%"],
			center: ['50%', '65%'],
			data: gonglvArr,
			label:{
				normal:{
					formatter: '{c} ({d}%)',// //饼图边的脚数据
				}
			},
			itemStyle: {
				normal: {
					color: function(params) {
						// 自定义饼图颜色
						var colorList = [
							 '#0FEB8B', '#DE67F4', '#08A0B7',
							'#21E0DA', '#33B565','#6778F4',
						];
						return colorList[params.dataIndex]
					}
				}

			}
		}]
		
	};
	gongLvChart.setOption(gongLv_option);
	$(document).ready(function() {
		gongLvChart.resize();
	});
	window.addEventListener("resize", function() {
		gongLvChart.resize();
	})
}

/*功率因素结束*/


//健康指数 开始
//jiankang();
function jiankang(unitid,userid){
	var zhanDataArr=[],zhanNameArr = [],zhanValueArr=[],zhanStateArr=[];
	//new add 2019-4-1 S
	test();
	//得到当前用户下的所有站点的健康指数
	function test(){
		
	    //参数unitid单位id
	    var url="/bigscrenn/getUserJkzsValue?unitid="+unitid;
	     //alert("健康指数 url ="+url);
	    console.log("健康指数 url ="+url);
	    var defer = $.Deferred();
		 $.ajax({
		     cache: true,
		     type: "POST",
		     url:url,
		     data:"",
		     //async: false,				   
		     success: function(data){
		    	 defer.resolve(data);
	            //alert("健康指数 data = "+data);//健康指数
	            console.log("健康指数 data = "+data);
	            if(data!=''){
	            	zhanDataArr = data.split(';');
		            for(var i=0;i<zhanDataArr.length;i++){
		            	zhanNameArr.push(zhanDataArr[i].split(',')[0]);
		            	zhanValueArr.push(zhanDataArr[i].split(',')[1]);
		            	zhanStateArr.push(zhanDataArr[i].split(',')[2]);
		            }
		            if($("#health >li").length>0){
	            		$("#health").empty();
	            	}
		            for(var j=0;j<zhanNameArr.length;j++){
		            	$("#health").append('<li>'+zhanNameArr[j] + '<span class="glValue">&nbsp;'+ zhanStateArr[j] +' &nbsp;'+ zhanValueArr[j]+'分</span></li>');
		            }
		            //判断是中断 使其颜色更变
		            
		            $("#health li span").each(function() {
						if($(this).html().indexOf("中断") != -1) {
							$(this).css('color','#FFB800');
						}
					})
		            //alert("zhanNameArr = "+zhanNameArr.length);
	            }else{
            		$("#health").empty();
	            }
	            yn_jkzs = 1;
		     }
	     });
		 return defer.promise();
	}
	
	//new add 2019-4-1 E
}
//健康指数 结束

/*告警统计方法 开始
   得到站点分类或指定站点下的告警统计
   得到单位下所有站点告警统计 unitid 单位ID，userid 用户ID
*/
//gaojing(unitid,userid);
function gaojing(unitid,userid){
	 var url="/bigtongji/getWarningList?unitid="+unitid+"&userid="+userid;
	 var defer = $.Deferred();
	 $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     //async: false,
	     success: function(data){
	    	 defer.resolve(data);
	    	 var gjtjArr = [];
	         // alert("告警统计 = "+data);
	           console.log("告警统计 ="+data);
	           var dataObj=eval("("+data+")");//转换为json对象
	           //alert(dataObj);
	           console.log(dataObj);
	     	  for (var i = 0; i < dataObj.rows.length; i++) {
	     		  //名字
	     		var name= dataObj.rows[i].NAME;
	     		  //值
	     		var value= dataObj.rows[i].NUM;
	     		//alert(value);
	     		gjtjArr.push({"name":dataObj.rows[i].NAME+dataObj.rows[i].NUM,"value":dataObj.rows[i].NUM})
	     	  }
	     	 alarmTest(gjtjArr);
	     	 yn_gjtj = 1;
	     }
	 });
	 return defer.promise();
}

function alarmTest(gjtjArr){
	//alert("gjtjArr = "+gjtjArr);
	var alarmCountChart = echarts.init(document.getElementById("gaojingtongji"));
	var alarmCount_option = {
		title: {
			text: '告警统计',
			show:false,
			x: 'center',
			textStyle: {
				// 文字颜色
				color: '#fff',
				// 字体风格,'normal','italic','oblique'
				fontStyle: 'normal',
				// 字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 |
				// 400...
				fontWeight: '100',
				// 字体系列
				fontFamily: 'sans-serif',
				// 字体大小
				fontSize: 18
			}
		},
		tooltip: {
			trigger: 'item',
			formatter: "{a} <br/>{b} : {c} ({d}%)"
		},
		legend: {
			type: 'scroll',  			    //分页类型
			pageIconColor: '#6495ed',       //翻页下一页的三角按钮颜色
			pageIconInactiveColor: '#aaa',  //翻页（即翻页到头时）
			pageIconSize: 11,               //翻页按钮大小
			pageFormatter: '',				//隐藏翻页的数字
			pageButtonItemGap: -6,			//翻页按钮的两个之间的间距
			show:true,
			orient: 'vertical',// ''horizontal
			left: '10%',
			y: '20%',
			itemGap: 10,
			/* data: ['x座机房', 'x层厂房', '办公室', '照明'], */
			data: gjtjArr,
			textStyle: {
				// 文字颜色
				color: '#fff',
				// 字体风格,'normal','italic','oblique'
				fontStyle: 'normal',
				// 字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 |
				// 400...
				fontWeight: '100',
				// 字体系列
				fontFamily: 'sans-serif',
				// 字体大小
				　　　　fontSize: 14
			}
		},
		series: [{
			name: '告警统计',
			type: 'pie',
			radius: ["0%","50%"],
			center: ['80%', '50%'],
			data: gjtjArr,
			label:{
				normal:{
					show:false,
					formatter: '{c} ({d}%)',// //饼图边的脚数据
				}
			},
			itemStyle: {
				normal: {
					color: function(params) {
						// 自定义饼图颜色
						var colorList = [
							'#08b0c9' , '#0FEB8B',  '#DE67F4',
							'#21E0DA', '#33B565','#6778F4',
						];
						return colorList[params.dataIndex]
					}
				}

			}
		}]
	};
	alarmCountChart.setOption(alarmCount_option);
	$(document).ready(function() {
		alarmCountChart.resize();
	});
	window.addEventListener("resize", function() {
		alarmCountChart.resize();
	})
}
/*告警统计方法 结束*/

/*这个月的能耗比方法 开始
得到单位下所有站点本月能耗分类统计 unitid 单位ID，userid 用户ID
*/
//monthNengHao();
function monthNengHao(unitid,userid){
	var thisMonth_vArr = [];
	var url="/bigtongji/getLHBList?unitid="+unitid+"&userid="+userid;   
	//alert("月的能耗比 url = "+url);
	var defer = $.Deferred();
	 $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     //async: false,				   
	     success: function(data){
	    	 defer.resolve(data);
               //alert("月的能耗比 = "+data);
               console.log(data,"月的能耗比");
               var dataObj=eval("("+data+")");//转换为json对象 
               //alert(dataObj);
               //alert(dataObj);
               var map = new Array();//装数值
               var map2 = new Array();//
               var arr = new Array(); //装时间
               var name=[];
         	   for (var i = 0; i < dataObj.rows.length; i++) {
         		  //名字
         		var UNITNAME= dataObj.rows[i].UNITNAME;
         		name.push(UNITNAME);
         		  //值
         	    arr[i]=new Array(i); 
            	  map[i]=new Array(i); 
         		  for (var j = 0; j < dataObj.rows[i].zList.length; j++) {
            		 map[i][j]=dataObj.rows[i].zList[j].NAME;
            		 arr[i][j]=dataObj.rows[i].zList[j].VALUE;
                  }
         	  }
         	  //alert(name);alert(map); alert(arr);
         	  //alert(map[0]);
       	      for (var i = 0; i < arr.length;i++) {
     		  //循环这里得到本月能耗值
              }
         	  //console.log(JSON.stringify(arr),"本月能耗");
              //console.log(JSON.stringify(map),"本月能耗==");
       	      
       	      //mothNHEchart(name,arr);
       	      mothNHEchart(name,arr,map);
       	      yn_bynhb=1;
	     }
	 });
	 return defer.promise();
}

// 得到指定站点最近两月能耗比统计
function mothNHEchart(name,data,axisArr) {
	//alert("name="+name);
	
	var itemStyle=[{
		normal: {
			color: function(params) {
				// build a color map as your need.
				var colorList = [
					'#08b0c9'
				];
				return colorList[params.dataIndex]
			},
			barBorderRadius: 2,
		}
	},{
		normal: {
			color: function(params) {
				// build a color map as your need.
				var colorList = [
					'#0FEB8B',
				];
				return colorList[params.dataIndex]
			},
			barBorderRadius: 2,
		}
	},{
		normal: {
			color: function(params) {
				// build a color map as your need.
				var colorList = [
					 '#DE67F4',
				];
				return colorList[params.dataIndex]
			},
			barBorderRadius: 2,
		}
	},{
		normal: {
			color: function(params) {
				// build a color map as your need.
				var colorList = [
					 '#21E0DA',
				];
				return colorList[params.dataIndex]
			},
			barBorderRadius: 2,
		}
	}];
	
	
	var series = [];
	for(var i=0;i<name.length;i++){
		series.push({
            name:name[i],
            type:'bar',
            barCategoryGap: '30%',
            //stack: 'qq',
            data:data[i],
            itemStyle: itemStyle[i],
            itemStyle1:  {
				normal: {
					color: function(params) {
						// build a color map as your need.
						var colorList = [
							'#DE67F4'
						];
						return colorList[params.dataIndex]
					},
					barBorderRadius: 2,
				}
			},
        });
	}
	
	
	var thisTimeLoadChart = echarts.init(document.getElementById("month_nahaobi"));
	fhrl_option = {
			title: {
				text: '本月能耗比',
				show:false,
				x: 'center',
				textStyle: {
					// 文字颜色
					color: '#fff',
					// 字体风格,'normal','italic','oblique'
					fontStyle: 'normal',
					// 字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 |
					// 400...
					fontWeight: '100',
					// 字体系列
					fontFamily: 'sans-serif',
					// 字体大小
					　　　　fontSize: 18
				}
			},
	    tooltip : {
	        trigger: 'axis',
	        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
	            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
	        }
	    },
	    legend: {
	    	show:false,
	    	data:name,
	        //data:['直接访问','邮件营销','联盟广告','视频广告','搜索引擎','百度','谷歌','必应','其他']
	    },
	    grid: {
	        left: '1%',
	        right: '1%',
	        top:"10%",
	        bottom: '5%',
	        containLabel: true
	    },
	    xAxis : {
    	 type : 'category',
    	 axisLine: {
				show: true,
				lineStyle: {
					color: "#0258f0",
					width: 1,
					type: "solid"
				},
			},
			axisTick: {
				show: false
			},
			axisLabel: {
				textStyle: {
					color: '#fff',
					fontSize: '12'
				}
			},
			splitLine: {// 网格竖轴线
				show:false,
				lineStyle: {
					color: "rgba(255,255,255,.1)",
				}
			},
			data:axisArr[0],
			/*data: [
				'1',
				'2',
				'3',
				'4',
				'5',
				'6',
				'7',
				'8',
				'9',
				'10',
				'11',
				'12',
				'13',
				'14',
				'15',
				'16',
				'17',
				'18',
				'19',
				'20',
				'21',
				'22',
				'23',
				'24',
				'25',
				'26',
				'27',
				'28',
				'29',
				'30',
				'31'
			],*/
		
		},
	    yAxis : {
	    	 type : 'value',
	    	 data : ['本月负荷','本日负荷','实时负荷'],
				axisLabel: {
					inside: false,
					textStyle: {
						color: '#fff',
						fontSize: '12'
					},
					interval: 0,
					rotate: "0"
				},
				axisTick: {
					show: false
				},
				axisLine: {
					show: true,
					lineStyle: {
						color: '#fdd',
						color: "#0258f0",
						width: 1,
						type: "solid"
					}
				},
				splitLine: {// 网格横轴线
					show:false,
					lineStyle: {
						color: "rgba(255,255,255,.1)",
					}
				}
	    	 
			
		},
		series:series,
	    /*series : [
	        {
	            name:'威默电气站点4',
	            type:'bar',
	            barCategoryGap: '60%',
	            stack: '广告',
	            data:["15.18","15.18","15.18","15.18","15.18","15.18","15.18","15.18","15.18","15.18","15.18","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],
	            itemStyle: { 
					normal: {
						color: function(params) {
							// build a color map as your need.
							var colorList = [
								'#0FEB8B'
							];
							return colorList[params.dataIndex]
						},
						barBorderRadius: 2,
					}
				},
	        },
	        {
	            name:'威默电气站点3',
	            type:'bar',
	            stack: '广告',
	            data:["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],
	            itemStyle: {
					normal: {
						color: function(params) {
							// build a color map as your need.
							var colorList = [
								'#DE67F4'
							];
							return colorList[params.dataIndex]
						},
						barBorderRadius: 2,
					}
				},
	        },
	        {
	            name:'威默电气站点2',
	            type:'bar',
	            stack: '广告',
	            data:["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],
	            itemStyle: {
					normal: {
						color: function(params) {
							// build a color map as your need.
							var colorList = [
								 '#21E0DA'
							];
							return colorList[params.dataIndex]
						},
						barBorderRadius: 2,
					}
				},
	        },
	        {
	            name:'威默电气',
	            type:'bar',
	            stack: '广告',
	            data:["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],
	            itemStyle: {
					normal: {
						color: function(params) {
							// build a color map as your need.
							var colorList = [
								 '#448DFE',
							];
							return colorList[params.dataIndex]
						},
						barBorderRadius: 2,
					}
				},
	        }
	    ]*/
	};
	thisTimeLoadChart.setOption(fhrl_option);
	$(document).ready(function() {
		thisTimeLoadChart.resize();
	});
	window.addEventListener("resize", function() {
		thisTimeLoadChart.resize();
	});

}

//================
function lateleEng(VArr1, VArr2) {
	var latelyEnergyChart = echarts.init(document.getElementById("lately_energy"));
	latelyEnergy_option = {
		 // backgroundColor: '#00265f',
// backgroundColor: 'rgb(0, 35, 120, .36)',
		title: {
			text: '最近两月能耗比',
			show:false,
			x: '2%',
			textStyle: {
				// 文字颜色
				color: '#fff',
				// 字体风格,'normal','italic','oblique'
				fontStyle: 'normal',
				// 字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 |
				// 400...
				fontWeight: '100',
				// 字体系列
				fontFamily: 'sans-serif',
				// 字体大小
				　　　　fontSize: 18
			}
		},
		tooltip: {
			trigger: 'axis',
			axisPointer: {
				type: 'shadow'
			}
		},
		legend: {
			show:false,
			data: ['本月', '上月'],
			align: 'left',
			left: '2%',
			top: '12%',
			textStyle: {
				color: "#fff",
				fontSize: 10
			},
			itemWidth: 10,
			itemHeight: 10,
			itemGap: 10
		},
		grid: {
			left: '2%',
			top: '10%',
			right: '2%',
			bottom: '2%',
			containLabel: true
		},
		xAxis: [{
			type: 'category',
			data: [
				'1',
				'2',
				'3',
				'4',
				'5',
				'6',
				'7',
				'8',
				'9',
				'10',
				'11',
				'12',
				'13',
				'14',
				'15',
				'16',
				'17',
				'18',
				'19',
				'20',
				'21',
				'22',
				'23',
				'24',
				'25',
				'26',
				'27',
				'28',
				'29',
				'30',
				'31'
			],
			axisLine: {
				show: true,
				lineStyle: {
					color: "rgba(255,255,255,.1)",
					width: 1,
					type: "solid"
				},
			},
			axisTick: {
				show: false,
			},
			axisLabel: {
				interval: 0,
				// rotate:50,
				show: true,
				splitNumber: 15,
				textStyle: {
					fontFamily: "微软雅黑",
					color: "#fff",
					fontSize: '120%',
				},
			},
		}],
		yAxis: [{
			type: 'value',
			axisLabel: {
				// formatter: '{value} %'
				show: false,
			},
			axisTick: {
				show: false,
			},
			axisLine: {
				show: true,
				lineStyle: {
					color: "rgba(255,255,255,.1	)",
					width: 1,
					type: "solid"
				},
			},
			splitLine: {
				lineStyle: {
					color: "rgba(255,255,255,.1)",
				}
			}
		}],
		series: [{
			name: '本月',
			type: 'bar',
			data: VArr1,
			barWidth: '30%', // 柱子宽度
			// barGap: 1, //柱子之间间距

			itemStyle: {
				normal: {
					color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
						offset: 0,
						color: '#3ca1ff'
					}, {
						offset: 1,
						color: '#0a73d5'
					}]),
					opacity: 1,
					barBorderRadius: 50,
				}
			}
		}, {
			name: '上月',
			type: 'bar',
			data: VArr2,
			barWidth: '30%',
			// barGap: 1,
			itemStyle: {
				normal: {
					color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
						offset: 0,
						color: '#DE67F4'
					}, {
						offset: 1,
						color: '#C97ED6'
					}]),
					opacity: 1,
					barBorderRadius: 50,
				}
			}
		}, ]
	};
	latelyEnergyChart.setOption(latelyEnergy_option);
	$(document).ready(function() {
		latelyEnergyChart.resize();
	});
	window.addEventListener("resize", function() {
		latelyEnergyChart.resize();
	})
}
/*这个月的能耗比方法 结束*/

//------------new add 2019-05-23 S---------------
//得到负荷容量实时曲线 参数userid用户id,unitid站点id
function resetFuheFunc(unitid,userid){//得到负荷容量实时曲线
 //var url="/bigtongji/getFhylList?unitid=010000000000&userid=000000000001";   
 var url="/bigtongji/getFhylList?unitid="+unitid+"&userid="+userid;
 var defer = $.Deferred();
 $.ajax({
      cache: true,
      type: "POST",
      url:url,
      data:"",
      //async: false,       
      success: function(data){
    	  defer.resolve(data);
               //alert(data);
               console.log(data);
               //alert(typeof data);// 判断是不是对象，然后判断是不是数组
               var dataObj=JSON.parse(data);
               // var dataObj=eval("("+data+")");//转换为json对象
               // alert(dataObj);
               //alert(dataObj);
               
               var resmap = [];
               var resarr = [];
               var rescon = [];
               var resname = [];
          
               var map = new Array();// 装数值1
               var map1 = new Array();// 装数值2
               var map2 = new Array();// 装数值3
               var map3 = new Array();// 装数值4
               
               
               var arr = new Array(); // 装时间1
               var arr1 = new Array(); // 装时间2
               var arr2 = new Array(); // 装时间3
               var arr3= new Array(); // 装时间4
               
               var con = new Array(); // 装单位1
               var con1 = new Array(); // 装单位2
               var con2 = new Array(); // 装单位3
               var con3 = new Array(); // 装单位4
               /* =============1号======================== */
               var map_0 = new Array();// 装数值1
               var map_1 = new Array();// 装数值2
               var map_2 = new Array();// 装数值3
               var map_3 = new Array();// 装数值4
               
               var arr_0 = new Array(); // 装时间1
               var arr_1 = new Array(); // 装时间2
               var arr_2 = new Array(); // 装时间3
               var arr_3= new Array(); // 装时间4
               
               var con_0 = new Array(); // 装单位1
               var con_1 = new Array(); // 装单位2
               var con_2 = new Array(); // 装单位3
               var con_3 = new Array(); // 装单位4
        /* ===================================== */
           /* =============2号======================== */
               var map1_0 = new Array();// 装数值1
               var map1_1 = new Array();// 装数值2
               var map1_2 = new Array();// 装数值3
               var map1_3 = new Array();// 装数值4
               
               var arr1_0 = new Array(); // 装时间1
               var arr1_1 = new Array(); // 装时间2
               var arr1_2 = new Array(); // 装时间3
               var arr1_3= new Array(); // 装时间4
               
               var con1_0 = new Array(); // 装单位1
               var con1_1 = new Array(); // 装单位2
               var con1_2 = new Array(); // 装单位3
               var con1_3 = new Array(); // 装单位4
        /* ===================================== */
           /* =============3号======================== */
               var map2_0 = new Array();// 装数值1
               var map2_1 = new Array();// 装数值2
               var map2_2 = new Array();// 装数值3
               var map2_3 = new Array();// 装数值4
               
               var arr2_0 = new Array(); // 装时间1
               var arr2_1 = new Array(); // 装时间2
               var arr2_2 = new Array(); // 装时间3
               var arr2_3= new Array(); // 装时间4
               
               var con2_0 = new Array(); // 装单位1
               var con2_1 = new Array(); // 装单位2
               var con2_2 = new Array(); // 装单位3
               var con2_3 = new Array(); // 装单位4
           /* ===================================== */
           /* =============4号======================== */
               var map3_0 = new Array();// 装数值1
               var map3_1 = new Array();// 装数值2
               var map3_2 = new Array();// 装数值3
               var map3_3 = new Array();// 装数值4
               
               var arr3_0 = new Array(); // 装时间1
               var arr3_1 = new Array(); // 装时间2
               var arr3_2 = new Array(); // 装时间3
               var arr3_3= new Array(); // 装时间4
               
               var con3_0 = new Array(); // 装单位1
               var con3_1 = new Array(); // 装单位2
               var con3_2 = new Array(); // 装单位3
               var con3_3 = new Array(); // 装单位4
        /* ===================================== */
               var name=[];
               // 1号变压器
               if(dataObj.rows.length!=0) {
                    for (var i = 0; i < dataObj.rows.length; i++) {
                     // 名字
                   var name= dataObj.rows[i].NAME;
                   resname.push(name);
                     // 负荷容量
                   var value= dataObj.rows[i].FNAME;
	              	
	            if( dataObj.rows[i].retList_0 != "undefined" && dataObj.rows[i].retList_0 != null && dataObj.rows[i].retList_0 != ""){
                   for(var j = 0; j < dataObj.rows[i].retList_0.length; j++) {
                	   // 值
                	    // map_0[i][j]=dataObj.rows[i].retList_0[j].VALUEA;
                	    map_0.push(dataObj.rows[i].retList_0[j].VALUEA);// 将每一次循环创建的对象push到数组中去
                	    // 时间
                		arr_0.push(dataObj.rows[i].retList_0[j].CDATE);
                		   // 单位
                		con_0.push(dataObj.rows[i].retList_0[j].CONVERSION);
                   }
	            } 
	            if( dataObj.rows[i].retListone_0 != "undefined" && dataObj.rows[i].retListone_0 != null && dataObj.rows[i].retListone_0 != ""){
	                   for(var j = 0; j < dataObj.rows[i].retListone_0.length; j++) {
	                	   // 值
	                	    map_1.push(dataObj.rows[i].retListone_0[j].VALUEA);
	                	    // 时间
	                		arr_1.push(dataObj.rows[i].retListone_0[j].CDATE);
	                		   // 单位
	                		con_1.push(dataObj.rows[i].retListone_0[j].CONVERSION);
	                   }
		            } if( dataObj.rows[i].retListtwo_0 != "undefined" && dataObj.rows[i].retListtwo_0 != null && dataObj.rows[i].retListtwo_0 != ""){
		                   for(var j = 0; j < dataObj.rows[i].retListtwo_0.length; j++) {
		                	   // 值
		                	    map_2.push(dataObj.rows[i].retListtwo_0[j].VALUEA);
		                	    // 时间
		                		arr_2.push(dataObj.rows[i].retListtwo_0[j].CDATE);
		                		   // 单位
		                		con_2.push(dataObj.rows[i].retListtwo_0[j].CONVERSION);
		                   }
			            } 
		            if( dataObj.rows[i].retListthree_0  != "undefined" && dataObj.rows[i].retListthree_0 != null && dataObj.rows[i].retListthree_0 != ""){
	                   for(var j = 0; j < dataObj.rows[i].retListthree_0.length; j++) {
	                	   // 值
	                	    map_3.push(dataObj.rows[i].retListthree_0[j].VALUEA);
	                	    // 时间
	                		arr_3.push(dataObj.rows[i].retListthree_0[j].CDATE);
	                		   // 单位
	                		con_3.push(dataObj.rows[i].retListthree_0[j].CONVERSION);
	                   }
		            }
		           if( dataObj.rows[i].retList_1 != "undefined" && dataObj.rows[i].retList_1 != null && dataObj.rows[i].retList_1 != ""){
		              for(var j = 0; j < dataObj.rows[i].retList_1.length; j++) {
		           	   // 值
		           	    map1_0.push(dataObj.rows[i].retList_1[j].VALUEA);
		           	    // 时间
		           		arr1_0.push(dataObj.rows[i].retList_1[j].CDATE);
		           		   // 单位
		           		con1_0.push(dataObj.rows[i].retList_1[j].CONVERSION);
		              }
		           } 
		           if( dataObj.rows[i].retListone_1 != "undefined" && dataObj.rows[i].retListone_1 != null && dataObj.rows[i].retListone_1 != ""){
		                  for(var j = 0; j < dataObj.rows[i].retListone_1.length; j++) {
		               	   // 值
		               	    map1_1.push(dataObj.rows[i].retListone_1[j].VALUEA);
		               	    // 时间
		               		arr1_1.push(dataObj.rows[i].retListone_1[j].CDATE);
		               		   // 单位
		               		con1_1.push(dataObj.rows[i].retListone_1[j].CONVERSION);
		                  }
		 	            }
		           if( dataObj.rows[i].retListtwo_1 != "undefined" && dataObj.rows[i].retListtwo_1 != null && dataObj.rows[i].retListtwo_1 != ""){
 	                   for(var j = 0; j < dataObj.rows[i].retListtwo_1.length; j++) {
 	                	   // 值
 	                	    map1_2.push(dataObj.rows[i].retListtwo_1[j].VALUEA);
 	                	    // 时间
 	                		arr1_2.push(dataObj.rows[i].retListtwo_1[j].CDATE);
 	                		   // 单位
 	                		con1_2.push(dataObj.rows[i].retListtwo_1[j].CONVERSION);
 	                   }
 		            } 
	 	            if( dataObj.rows[i].retListthree_1  != "undefined" && dataObj.rows[i].retListthree_1 != null && dataObj.rows[i].retListthree_1 != ""){
	                   for(var j = 0; j < dataObj.rows[i].retListthree_1.length; j++) {
	                	   // 值
	                	    map1_3.push(dataObj.rows[i].retListthree_1[j].VALUEA);
	                	    // 时间
	                		arr1_3.push(dataObj.rows[i].retListthree_1[j].CDATE);
	                		   // 单位
	                		con1_3.push(dataObj.rows[i].retListthree_1[j].CONVERSION);
	                   }
		            }
	 	            if( dataObj.rows[i].retList_2 != "undefined" && dataObj.rows[i].retList_2 != null && dataObj.rows[i].retList_2 != ""){
	 		           for(var j = 0; j < dataObj.rows[i].retList_2.length; j++) {
	 		        	   // 值
	 		        	    map2_0.push(dataObj.rows[i].retList_2[j].VALUEA);
	 		        	    // 时间
	 		        		arr2_0.push(dataObj.rows[i].retList_2[j].CDATE);
	 		        		   // 单位
	 		        		con2_0.push(dataObj.rows[i].retList_2[j].CONVERSION);
	 		           }
	 		        } 
	 		        if( dataObj.rows[i].retListone_2 != "undefined" && dataObj.rows[i].retListone_2 != null && dataObj.rows[i].retListone_2 != ""){
 		               for(var j = 0; j < dataObj.rows[i].retListone_2.length; j++) {
 		            	   // 值
 		            	    map2_1.push(dataObj.rows[i].retListone_2[j].VALUEA);
 		            	    // 时间
 		            		arr2_1.push(dataObj.rows[i].retListone_2[j].CDATE);
 		            		   // 单位
 		            		con2_1.push(dataObj.rows[i].retListone_2[j].CONVERSION);
 		               }
	 	            }
	 		        if( dataObj.rows[i].retListtwo_2 != "undefined" && dataObj.rows[i].retListtwo_2 != null && dataObj.rows[i].retListtwo_2 != ""){
 	                   for(var j = 0; j < dataObj.rows[i].retListtwo_2.length; j++) {
 	                	   // 值
 	                	    map2_2.push(dataObj.rows[i].retListtwo_2[j].VALUEA);
 	                	    // 时间
 	                		arr2_2.push(dataObj.rows[i].retListtwo_2[j].CDATE);
 	                		   // 单位
 	                		con2_2.push(dataObj.rows[i].retListtwo_2[j].CONVERSION);
 	                   }
 		            } 
	 	            if( dataObj.rows[i].retListthree_2  != "undefined" && dataObj.rows[i].retListthree_2 != null && dataObj.rows[i].retListthree_2 != ""){
	                   for(var j = 0; j < dataObj.rows[i].retListthree_2.length; j++) {
	                	   // 值
	                	    map2_3.push(dataObj.rows[i].retListthree_2[j].VALUEA);
	                	    // 时间
	                		arr2_3.push(dataObj.rows[i].retListthree_2[j].CDATE);
	                		   // 单位
	                		con2_3.push(dataObj.rows[i].retListthree_2[j].CONVERSION);
	                   }
		            }
 		 	        if( dataObj.rows[i].retList_3 != "undefined" && dataObj.rows[i].retList_3 != null && dataObj.rows[i].retList_3 != ""){
 			           for(var j = 0; j < dataObj.rows[i].retList_3.length; j++) {
 			        	   // 值
 			        	    map3_0.push(dataObj.rows[i].retList_3[j].VALUEA);
 			        	    // 时间
 			        		arr3_0.push(dataObj.rows[i].retList_3[j].CDATE);
 			        		   // 单位
 			        		con3_0.push(dataObj.rows[i].retList_3[j].CONVERSION);
 			           }
 			        } 
 			        if( dataObj.rows[i].retListone_3 != "undefined" && dataObj.rows[i].retListone_3 != null && dataObj.rows[i].retListone_3 != ""){
 			               for(var j = 0; j < dataObj.rows[i].retListone_3.length; j++) {
 			            	   // 值
 			            	    map3_1.push(dataObj.rows[i].retListone_3[j].VALUEA);
 			            	    // 时间
 			            		arr3_1.push(dataObj.rows[i].retListone_3[j].CDATE);
 			            		   // 单位
 			            		con3_1.push(dataObj.rows[i].retListone_3[j].CONVERSION);
 			               }
 			 	            } 
 			        if( dataObj.rows[i].retListtwo_3 != "undefined" && dataObj.rows[i].retListtwo_3 != null && dataObj.rows[i].retListtwo_3 != ""){
 	                   for(var j = 0; j < dataObj.rows[i].retListtwo_3.length; j++) {
 	                	   // 值
 	                	    map3_2.push(dataObj.rows[i].retListtwo_3[j].VALUEA);
 	                	    // 时间
 	                		arr3_2.push(dataObj.rows[i].retListtwo_3[j].CDATE);
 	                		   // 单位
 	                		con3_2.push(dataObj.rows[i].retListtwo_3[j].CONVERSION);
 	                   }
 		            } 
	 	            if( dataObj.rows[i].retListthree_3  != "undefined" && dataObj.rows[i].retListthree_3 != null && dataObj.rows[i].retListthree_3 != ""){
	                   for(var j = 0; j < dataObj.rows[i].retListthree_3.length; j++) {
	                	   // 值
	                	    map3_3.push(dataObj.rows[i].retListthree_3[j].VALUEA);
	                	    // 时间
	                		arr3_3.push(dataObj.rows[i].retListthree_3[j].CDATE);
	                		   // 单位
	                		con3_3.push(dataObj.rows[i].retListthree_3[j].CONVERSION);
	                   }
		            }
		            
                }
          } 
   
           /* ==============1号=================== */
            if (map_0.length != 0&& arr_0.length != 0 && con_0.length != 0){
            map=map.concat(map_0)    ;
             console.log(map);
        	 arr=arr.concat(arr_0)    ;
             console.log(arr);
             con=con.concat(con_0)    ;
             console.log(con);
            }
            if (map_1.length != 0&& arr_1.length != 0 && con_1.length != 0){
            	
                map=map.concat(map_1)    ;
                 console.log(map);
            	 arr=arr.concat(arr_1)    ;
                 console.log(arr);
                 con=con.concat(con_1)    ;
                 console.log(con);
                }
            if (map_2.length != 0&& arr_2.length != 0 && con_2.length != 0){
                map=map.concat(map_2)    ;
                 console.log(map);
            	 arr=arr.concat(arr_2)    ;
                 console.log(arr);
                 con=con.concat(con_2)    ;
                 console.log(con);
                }
            if (map_3.length != 0&& arr_3.length != 0 && con_3.length != 0){
                map=map.concat(map_3)    ;
                 console.log(map);
            	 arr=arr.concat(arr_3)    ;
                 console.log(arr);
                 con=con.concat(con_3)    ;
                 console.log(con);
                }
          /* ==============2号=================== */
            if (map1_0.length != 0&& arr1_0.length != 0 && con1_0.length != 0){
	        	//alert(map1_0);
	        	//alert(map1_0.length);
	            map=map.concat(map1_0)    ;
	             console.log(map);
	        	 arr=arr.concat(arr1_0)    ;
	             console.log(arr);
	             con=con.concat(con1_0)    ;
	             console.log(con);
            }
            if (map1_1.length != 0&& arr1_1.length != 0 && con1_1.length != 0){
                 map=map.concat(map1_1)    ;
                 console.log(map);
            	 arr=arr.concat(arr1_1)    ;
                 console.log(arr);
                 con=con.concat(con1_1)    ;
                 console.log(con);
            }
                if (map1_2.length != 0&& arr1_2.length != 0 && con1_2.length != 0){
                    map=map.concat(map1_2)    ;
	                 console.log(map);
	            	 arr=arr.concat(arr1_2)    ;
	                 console.log(arr);
	                 con=con.concat(con1_2)    ;
	                 console.log(con);
                    }
                if (map1_3.length != 0&& arr1_3.length != 0 && con1_3.length != 0){
                    map=map.concat(map1_3)    ;
	                 console.log(map);
	            	 arr=arr.concat(arr1_3)    ;
	                 console.log(arr);
	                 con=con.concat(con1_3)    ;
	                 console.log(con);
                    }
                /* ==============3号=================== */
                if (map2_0.length != 0&& arr2_0.length != 0 && con2_0.length != 0){
                    map=map.concat(map2_0)    ;
	                 console.log(map);
	            	 arr=arr.concat(arr2_0)    ;
	                 console.log(arr);
	                 con=con.concat(con2_0)    ;
	                 console.log(con);
                    }
                    if (map2_1.length != 0&& arr2_1.length != 0 && con2_1.length != 0){
                        map=map.concat(map2_1)    ;
    	                 console.log(map);
    	            	 arr=arr.concat(arr2_1)    ;
    	                 console.log(arr);
    	                 con=con.concat(con2_1)    ;
    	                 console.log(con);
                        }
                    if (map2_2.length != 0&& arr2_2.length != 0 && con2_2.length != 0){
                        map=map.concat(map2_2)    ;
    	                 console.log(map);
    	            	 arr=arr.concat(arr2_2)    ;
    	                 console.log(arr);
    	                 con=con.concat(con2_2)    ;
    	                 console.log(con);
                        }
                    if (map2_3.length != 0&& arr2_3.length != 0 && con2_3.length != 0){
                        map=map.concat(map2_3)    ;
    	                 console.log(map);
    	            	 arr=arr.concat(arr2_3)    ;
    	                 console.log(arr);
    	                 con=con.concat(con2_3)    ;
    	                 console.log(con);
                        }
                    /* ==============4号=================== */
                    if (map3_0.length != 0&& arr3_0.length != 0 && con3_0.length != 0){
                        map=map.concat(map3_0)    ;
    	                 console.log(map);
    	            	 arr=arr.concat(arr3_0)    ;
    	                 console.log(arr);
    	                 con=con.concat(con3_0)    ;
    	                 console.log(con);
                    }
                    if (map3_1.length != 0&& arr3_1.length != 0 && con3_1.length != 0){
                        map=map.concat(map3_1)    ;
    	                 console.log(map);
    	            	 arr=arr.concat(arr3_1)    ;
    	                 console.log(arr);
    	                 con=con.concat(con3_1)    ;
    	                 console.log(con);
                    }
                    if (map3_2.length != 0&& arr3_2.length != 0 && con3_2.length != 0){
                        map=map.concat(map3_2)    ;
    	                 console.log(map);
    	            	 arr=arr.concat(arr3_2)    ;
    	                 console.log(arr);
    	                 con=con.concat(con3_2)    ;
    	                 console.log(con);
                    }
                    if (map3_3.length != 0&& arr3_3.length != 0 && con3_3.length != 0){
                        map=map.concat(map3_3)    ;
    	                 console.log(map);
    	            	 arr=arr.concat(arr3_3)    ;
    	                 console.log(arr);
    	                 con=con.concat(con3_3)    ;
    	                 console.log(con);
                    }
                        
                    //alert(map);    alert(arr);    alert(con);
                    var len = map.length;
                    var n = 10; // 每行显示10个
                    var lineNum = len % 10 === 0 ? len / 10 : Math.floor( (len / 10) + 1 );
                      
                    for (var i = 0; i < lineNum; i++) {
                        // slice()
						// 方法返回一个从开始到结束（不包括结束）选择的数组的一部分浅拷贝到一个新数组对象。且原始数组不会被修改。
	                      var  temp1 = map.slice(i*n, i*n+n);
	                       var  temp2 = arr.slice(i*n, i*n+n);
	                      var  temp3 = con.slice(i*n, i*n+n); 
	                      resmap.push(temp1);
	                      resarr.push(temp2);
	                      rescon.push(temp3); 
                    }
                    console.log(resname);
                    console.log(resmap);
                    console.log(resarr);
                    console.log(rescon);
                     
                   //alert("map.length -----www  = "+JSON.stringify(map));
 		           // alert("newName = "+newName.length);
 		           //传到弹框使用
 		           var fhrlObj = {"name":resname,"time":resarr,"danwei":rescon,"value":resmap};
 		           localStorage.setItem("fhrl",JSON.stringify(fhrlObj));
 		           rongLiangFunc(resmap,resname);
 		          yn_fhrl = 1;

      }
 });
 return defer.promise();
 
}  

//------------new add 2019-05-23 S---------------



/* 实时负荷 容量方法 开始*/
//得到负荷容量实时曲线 参数userid用户id,unitid站点id
function fuheFunc(unitid,userid){//得到负荷容量统计
	var nameArr = [],shishiArr = [],todayArr = [],monthArr = [],fhrlArr = [],fh_dataArr = [];
	var url="/bigtongji/getFhylList?unitid="+unitid+"&userid="+userid; 
	//alert("负荷容量 url = "+url);
	var defer = $.Deferred();
	 $.ajax({
	    cache: true,
	    type: "POST",
	    url:url,
	    data:"",
	    async: false,       
	    success: function(data){
	    	defer.resolve(data);
             //alert(data);
             console.log("负荷容量data = "+data,"负荷容量data = ");
             var dataObj=eval("("+data+")");//转换为json对象 
             //alert(dataObj);
             //alert(dataObj);
             var map = new Array();//装数值
             var map2 = new Array();//
             var arr = new Array(); //装时间
             var con = new Array(); //装单位
             var name=[];
             
             
             localStorage.setItem("upDataNum",dataObj.rows[0].retList.length);//用于弹框的高度
             
             for (var i = 0; i < dataObj.rows.length; i++) {
               //名字
             var name= dataObj.rows[i].UNITNAME;
               //负荷容量
             var value= dataObj.rows[i].FNAME;
             arr[i]=new Array(i); 
        	  map[i]=new Array(i); 
        	 con[i]=new Array(i); 
             //alert(value);
        	 
        	 nameArr.push(dataObj.rows[i].NAME);
        	 
             for(var j = 0; j < dataObj.rows[i].retList.length; j++) {
          	   //值
          	    map[i][j]=dataObj.rows[i].retList[j].VALUEA;
          	    //时间
          		arr[i][j]=dataObj.rows[i].retList[j].CDATE;
          		   //单位
          		con[i][j]=dataObj.rows[i].retList[j].CONVERSION;
             }
          }
          //    alert("站点名nameArr = "+nameArr.length);   
          //alert(map);  alert(arr);  alert(con);
          //alert("arr = "+arr[0].length);
           
          console.log(map);
          console.log(arr); 
          console.log(con);
          
          //传到弹框使用
          var fhrlObj = {"name":nameArr,"time":arr,"danwei":con,"value":map};
          //localStorage.setItem("fhrl",JSON.stringify(fhrlObj));
          //var fhrlObj = localStorage.getItem("fhrl");
			//alert("---"+fhrlObj);
          //rongLiangFunc(map,nameArr);
          yn_ssfh = 1;
	    }
	});
	 return defer.promise();
}

function rongLiangFunc(valueArr,legendArr){
	
	var colorArr = [];
	var borderColor = [];
	borderColor.push({
		color: '#08b0c9',
		borderColor: '#08b0c9',
		borderWidth: 12
	}, {
		color: '#0FEB8B',
		borderColor: '#0FEB8B',
		borderWidth: 12
	}, {
		color: '#DE67F4',
		borderColor: '#DE67F4',
		borderWidth: 12
	},{
		color: '#21E0DA',
		borderColor: '#21E0DA',
		borderWidth: 12
	},{
		color: 'orange',
		borderColor: 'orange',
		borderWidth: 12
	},{
		color: 'yellow',
		borderColor: 'yellow',
		borderWidth: 12
	})
	//colorArr.push();
	//alert("colorArr.length = " + colorArr.length);
	//alert(" valueArr.length = " + valueArr.length);
	var series = [];
	for(var i = 0; i < valueArr.length; i++) {
		//valueArr[i]

		series.push({
			name: legendArr[i],
			//name: 'A相电流',
			type: 'line',
			smooth: true,
			symbol: 'circle',
			symbolSize: 5,
			showSymbol: false,
			lineStyle: {
				normal: {
					width: 2
				}
			},
			areaStyle: {
				normal: {color:'transparent'},
			},
			itemStyle: {
				normal: borderColor[i],
				normal1: {
					color: '#f4a240',
					borderColor: 'rgba(137,189,2,0.27)',
					borderWidth: 12
				}
			},
			//data: [, , , 34, 110, 220, 150, 75, 30, , , ]
			data: valueArr[i]
		})

	}
	//alert("var series = " + series.length);
	
	
	var thisTimeLoadChart = echarts.init(document.getElementById("fhrlID"));
	fhrl_option = {
			backgroundColor: "rgb(0,0,0,.2)",
			title:{
				show:false,
				text:'实时负荷1',
				x: 'center',
				y:'3%',
				textStyle: {
					// 文字颜色
					color: '#fff',
					// 字体风格,'normal','italic','oblique'
					fontStyle: 'normal',
					// 字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 |
					// 400...
					fontWeight: '100',
					// 字体系列
					fontFamily: 'sans-serif',
					// 字体大小
					fontSize: 20
				}
			},
			tooltip: {
				trigger: 'axis',
				axisPointer: {
					lineStyle: {
						color: '#57617B'
					}
				}
			},
			legend: {
				show:false,
				icon: 'rect',
				data: legendArr,
				//data: ['A相电流', 'B相电流', 'C相电流'],
				align: 'right',
				right: '2%',
				top: '5%',
				textStyle: {
					color: "#fff"
				},
				itemWidth: 30,
				itemHeight: 10,
				itemGap: 15
			},
			grid: {
				left: '2%',
				right: '2%',
				top: '5%',
				bottom: '10%',
				containLabel: true
			},
			xAxis: [{
				type: 'category',
				boundaryGap: false,
				axisLine: {
					lineStyle: {
						color: '#fff'
					}
				},
				//						data: Xarr,
				data: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
			}, {
				axisLine: {
					show: false, //上横轴
					lineStyle: {
						color: 'red',
					}
				},

			}],
			yAxis: [{
				axisLabel: {
					show: true,
					formatter: '{value}'
				},
				splitLine: {
					lineStyle: {
						color: 'rgba(255,255,255,.1)'
					}
				},
				axisLine: {
					lineStyle: {
						color: '#fff'
					}
				},
			}],
			series: series,
			series1: [{
				//						name: legenArr[0],
				name: 'A相电流',
				type: 'line',
				smooth: true,
				symbol: 'circle',
				symbolSize: 5,
				showSymbol: false,
				lineStyle: {
					normal: {
						width: 2
					}
				},
				areaStyle: {
					normal: {
						color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
							offset: 0.99,
							color: 'rgba(222,103,244, 0.2)'
						}, {
							offset: 0.9,
							color: 'rgba(222,103,244, 0.3)'
						}, {
							offset: 0.7,
							color: 'rgba(222,103,244, 0.5)'
						}, {
							offset: 0.5,
							color: 'rgba(222,103,244, 0.7)'
						}, {
							offset: 0.3,
							color: 'rgba(222,103,244, 0.8)'
						}, {
							offset: 0.1,
							color: 'rgba(222,103,244, 0.99)'
						}], false),
						shadowColor: 'rgba(0, 0, 0, 0.9)',
						shadowBlur: 10
					}
				},
				itemStyle: {
					normal: {
						color: '#f4a240',
						borderColor: 'rgba(137,189,2,0.27)',
						borderWidth: 12
					}
				},
				data: [, , , 34, 110, 220, 150, 75, 30, , , ]
				//						data: dataA
			}, {
				//						name: legenArr[1],
				name: 'B相电流',
				type: 'line',
				smooth: true,
				symbol: 'circle',
				symbolSize: 5,
				showSymbol: false,
				lineStyle: {
					normal: {
						width: 2
					}
				},
				areaStyle: {
					normal: {
						color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
							offset: 0.99,
							color: 'rgba(79,148,255, 0.2)'
						}, {
							offset: 0.9,
							color: 'rgba(79,148,255, 0.4)'
						}, {
							offset: 0.7,
							color: 'rgba(79,148,255, 0.5)'
						}, {
							offset: 0.5,
							color: 'rgba(79,148,255, 0.66)'
						}, {
							offset: 0.3,
							color: 'rgba(79,148,255, 0.86)'
						}, {
							offset: 0.1,
							color: 'rgba(79,148,255, 0.99)'
						}], false),
						shadowColor: 'rgba(0, 0, 0, 0.9)',
						shadowBlur: 10
					}
				},
				itemStyle: {
					normal: {
						color: '#00ff00',
						borderColor: 'rgba(0,136,212,0.5)',
						borderWidth: 12
					}
				},
				data: [10, 180, 75, 145, 222, 165, 132, 200, 182, 61, 164, 50]
				//						data: dataB
			}, {
				//						name: legenArr[2],
				name: 'C相电流',
				type: 'line',
				smooth: true,
				symbol: 'circle',
				symbolSize: 5,
				showSymbol: false,
				lineStyle: {
					normal: {
						width: 2
					}
				},
				areaStyle: {
					normal: {
						color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
							offset: 0.99,
							color: 'rgba(15,235,139, 0.2)'
						}, {
							offset: 0.9,
							color: 'rgba(15,235,139, 0.4)'
						}, {
							offset: 0.7,
							color: 'rgba(15,235,139, 0.5)'
						}, {
							offset: 0.5,
							color: 'rgba(15,235,139, 0.66)'
						}, {
							offset: 0.3,
							color: 'rgba(15,235,139, 0.86)'
						}, {
							offset: 0.1,
							color: 'rgba(15,235,139, 0.99)'
						}], false),
						shadowColor: 'rgba(0, 0, 0, 0.9)',
						shadowBlur: 10
					}
				},
				itemStyle: {
					normal: {
						color: '#FFFF00',
						borderColor: 'rgba(0,136,212,0.5)',
						borderWidth: 12
					}
				},
				data: [120, 110, 125, 145, 122, 165, 122, 220, 182, 191, 134, 150]
				//data: dataC
			}]
	};
	thisTimeLoadChart.setOption(fhrl_option);
	$(document).ready(function() {
		thisTimeLoadChart.resize();
	});
	window.addEventListener("resize", function() {
		thisTimeLoadChart.resize();
	});

}

	
function Percentage(number1, number2) {
	return(Math.round(number1 / number2 * 10000) / 100.00 + "%"); // 小数点后两位百分比
}



// 用户选择 方法开始
$('#gollegebable').on('click',function(){
	//alert($("#dl dd").length)
	if($("#dl dd").length==0){
    	zhanDianNumFunc();
    }
	
})
// 用户选择方法结束

// 向上文字方法开始
//yxfxFunc();
function yxfxFunc(dwID){
	//alert("---2- dwID = "+dwID);
	$(document).ready(function() {
		$('.list_lh li:even').addClass('lieven');
	})
	
	$("div.list_lh").myScroll({
		speed: 60, // 数值越大，速度越慢
		rowHeight: 50 // li的高度(btn_lh,p高度的2倍)
	});
	
	
	
	// new add
	var msg_ul = document.getElementById("msg_ul");
	var userid,unitID,userType,dwID ;
	
	yunxingWeiHu(dwID);      
	        
	function yunxingWeiHu(dwID){
		//得到客户下所有站点的告警列表
	    //unitid客户的单位id，单位id为空时调用所有告警列表，如var url="/bigscrenn/getWarningUserList?unitid="
	    //var url="/bigscrenn/getWarningUserList?unitid=010000000000";
	    var url="/bigscrenn/getWarningUserList?unitid="+dwID;
	    //alert("所有站点 url = "+url);
	    var defer = $.Deferred();
		 $.ajax({
		     cache: true,
		     type: "POST",
		     url:url,
		     data:"",
		     //async: false,				   
		     success: function(data){
		    	 defer.resolve(data);
                   //alert("三级的告警信息 data = "+data);
		    	   console.log("告警信息 data = "+data);
                   //js解析json串
                   var obj = JSON.parse(data);
                   //alert(obj.total);//记录数
                   
                   var alarmInfoMsg_ul = document.getElementById("alarmInfoMsg_ul");//实时告警推送
	               localStorage.setItem("gjDataNum",obj.rows.length);//用于弹框
                   
	               if($("#msg_ul li").length>0){
                	   $("#msg_ul").empty();
                   }
	               //alert($("#msg_ul li").length);
	               //for (var i=0;i<obj.rows.length;i++)
                   for (var i=0;i<(obj.rows).slice(0,9).length;i++)
                   {
                         //alert(obj.rows[i].CID);   //告警id
                         //alert(obj.rows[i].WTITLE);//告警标题
                         //alert(obj.rows[i].WCONTENT);//告警内容
                         //alert(obj.rows[i].GJTYPE);//告警类别，0一般事件1报警事件 2 跳闸事件
                         //alert(obj.rows[i].CDATE);  //告警时间
                	     //var stre = "<li><p><a href='javascript:;' title="+obj.rows[i].CDATE+'>' + obj.rows[i].CDATE + "</a><a href='javascript:;' title="+obj.rows[i].WTITLE+'>' + obj.rows[i].WTITLE + "</a><a href='javascript:;' title="+obj.rows[i].WTITLE+'>' + obj.rows[i].WTITLE + "</a><a href='javascript:;' title="+obj.rows[i].WCONTENT+'>' + obj.rows[i].WCONTENT +"大幅度反对法大幅度"+ "</a></p></li>";
		            	 $("#msg_ul").append("<li><p><a href='javascript:;' title="+obj.rows[i].CDATE+'>' + obj.rows[i].CDATE +"<a style='display: none;'>"+obj.rows[i].GJTYPE+"</a>"+"<a href='javascript:;' title="+obj.rows[i].WTITLE+'>' + obj.rows[i].WTITLE +""+ "<span style='display: none;'>&nbsp;&nbsp;&nbsp;"+ obj.rows[i].GJTYPE+"</span></a><a style='display: none;'>"+obj.rows[i].WCONTENT+"</a></p></li>");
                   }
                   setTrColrFunc();  
                   
                   $("#msg_ul li").click(function(){
                	   var inedx = $(this).index();
    					//alert("inedx = "+inedx);
    					layer.open({
    						title:"告警信息",
    						center:"center",
    						type: 1,
    					    skin: 'layui-layer-rim', //加上边框
    						area: ['calc(30% - 50px)', '350px'], //宽高
    						//content: 'html内容',
    						content: '<div style="padding:20px;">'+$(this).html()+'</div>',
    					});
    					$(".layui-layer-rim p a").css({
       						'color':'#fff',
       						'display':'block',
       						'fontSize':'14px',
       						'lineHeight':'1.3rem'
       					});
        					$(".layui-layer-rim").css({
       						'border':'none',
       						'background':'#0055b3'
       					});
    					$(".layui-layer-rim a.layui-layer-ico").text('×').css({
    						'color':'#fff',
    						'fontSize':'2rem',
    						'margin-top': '-15px',
    						'background':'none'
    					});
    					
    					$(".layui-layer-rim .layui-layer-title").css({'background':'#0055b3','color':'#fff',});
                   })
                   yn_gjxx = 1;
                   //报警
                   if(obj.total>0){
                	   $("#audio-div").empty()
                	   $("#audio-div").append('<audio controls autoplay hidden><source src="warn.wav" type="audio/mpeg"></audio>'+
                			   '<audio controls autoplay hidden><source src="warn.mp3" type="audio/mpeg"></audio>');
                   }
		     }
	     });
		 return defer.promise();
	}
}



// 电气图全屏开始
function fullScreenBtn(urlStr){
	var urlStr = localStorage.getItem("urlStr");
	var ecURL = encodeURI(encodeURI(urlStr));   // 二次编码，适应ie浏览器识别中文问题
	var picName = localStorage.getItem("picName");
	 //alert("电气图进来的地址url:"+urlStr);
	if(ecURL){
		console.log("urlStr==:"+urlStr);
		// var url="/bigscrenn/getVlabelList?fid=000000000001";
		var index = layer.open({
		  type: 2,
		  title:picName,
		  content: ecURL,
		  area: ['320px', '195px'],
		  maxmin: false,                        // 开启最大化最小化按钮
		  skin: 'layui-layer-rim', //加上边框
		});
		layer.full(index);
		
		$(".layui-layer-rim p a").css({
			'color':'#fff',
			'display':'block',
			'fontSize':'14px',
			'lineHeight':'1.3rem'
		});
		$(".layui-layer-rim").css({
			'border':'none',
			'background':'#07256b'
		});
	$(".layui-layer-rim a.layui-layer-ico").text('×').css({
		'color':'#fff',
		'fontSize':'2rem',
		'margin-top': '-15px',
		'background':'none'
	});
	
	$(".layui-layer-rim .layui-layer-title").css({'background':'#07256b','color':'#fff',});
	}
	if(!ecURL){
		layer.msg('网络错误或加载数据失败');
	}
	
}
// 电气图全屏结束

//设备分类 开始

//获取设备分类数量数量   unitid 单位ID 用户ID userid
function shebeiFunc(unitid,userid){
	var url="/bigtongji/getDeviceStatistics?unitid="+unitid+"&userid="+userid;   
    //var url="/bigtongji/getDeviceStatistics?unitid=010000000000&userid=000000000001";   
	var defer = $.Deferred();
	 $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     //async: false,				   
	     success: function(data){
	    	 defer.resolve(data);
	           //alert("设备分类 = "+data);
	           console.log(data);
	           var dataObj=eval("("+data+")");//转换为json对象 
	           //alert(dataObj);
	           console.log(dataObj,"设备分类数据");
	         	var total= dataObj.total;
	         	//alert(total);
	            var map = new Array();//装数值
	            var map2 = new Array();//
	            var arr = new Array(); //装时间
	            var name=[];
	      	  for (var i = 0; i < dataObj.rows.length; i++) {
	      		  //名字
	      		var UNITNAME= dataObj.rows[i].UNITNAME;
	      		name.push(UNITNAME);
	      		  //值
	      	      arr[i]=new Array(i); 
	         	  map[i]=new Array(i); 
	      		  for (var j = 0; j < dataObj.rows[i].UnitList.length; j++) {
	         		 map[i][j]=dataObj.rows[i].UnitList[j].NAME;
	         		arr[i][j]=dataObj.rows[i].UnitList[j].NUM;
	               }
	      	  }
	      	 //alert(name);alert(map); alert(arr);
	      	 //设备分类名
	      	 //alert(map[0]);
	    	  for (var i = 0; i < arr.length;i++) {
	  		 //循环这里得到设备分类数量值
	         }
	      	  console.log(JSON.stringify(arr),"设备分类");
	           console.log(JSON.stringify(map),"设备分类==");
	           shebeiEchart(name,map,arr);
	           yn_sbfl = 1;
	     }
	});
	 return defer.promise();
}
function shebeiEchart(zdName,shebeiNum,fhData){
	//alert(fhData+"fhData");
	
	var itemStyle=[{
		normal: {
			color: function(params) {
				// build a color map as your need.
				var colorList = [
					'#08b0c9'
				];
				return colorList[params.dataIndex]
			},
			barBorderRadius: 2,
		}
	},{
		normal: {
			color: function(params) {
				// build a color map as your need.
				var colorList = [
					'#0FEB8B',
				];
				return colorList[params.dataIndex]
			},
			barBorderRadius: 2,
		}
	},{
		normal: {
			color: function(params) {
				// build a color map as your need.
				var colorList = [
					 '#DE67F4',
				];
				return colorList[params.dataIndex]
			},
			barBorderRadius: 2,
		}
	},{
		normal: {
			color: function(params) {
				// build a color map as your need.
				var colorList = [
					 '#21E0DA',
				];
				return colorList[params.dataIndex]
			},
			barBorderRadius: 2,
		}
	}];
	
	var series = [];
	for(var i=0;i<zdName.length;i++){
		//alert(fhData[i]+"fhData");
		series.push({
            name:zdName[i],
            type:'bar',
            barCategoryGap: '20%',
            //stack: '广告',
            data:fhData[i],
            itemStyle:itemStyle[i],
            itemStyle1: {
				normal: {
					color: function(params) {
						// build a color map as your need.
						var colorList = [
							'#0FEB8B'
						];
						return colorList[params.dataIndex]
					},
					barBorderRadius: 2,
				}
			},
        })
	}
	
	var thisTimeLoadChart = echarts.init(document.getElementById("deviceClassID"));
	fhrl_option = {
			title: {
				text: '设备分类',
				show:false,
				x: 'center',
				textStyle: {
					// 文字颜色
					color: '#fff',
					// 字体风格,'normal','italic','oblique'
					fontStyle: 'normal',
					// 字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 |
					// 400...
					fontWeight: '100',
					// 字体系列
					fontFamily: 'sans-serif',
					// 字体大小
					　　　　fontSize: 20
				}
			},
	    tooltip : {
	        trigger: 'axis',
	        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
	            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
	        }
	    },
	    legend: {
	    	show:false,
	        //data:['直接访问','邮件营销','联盟广告','视频广告','搜索引擎','百度','谷歌','必应','其他']
	    },
	    grid: {
	        left: '3%',
	        right: '4%',
	        top:"15%",
	        bottom: '0%',
	        containLabel: true
	    },
	    yAxis : {
    	 type : 'value',
    	 axisLine: {//横坐标轴
				show: true,
				lineStyle: {
					color: "#0258f0",
					width: 1,
					type: "solid"
				},
			},
			axisTick: {
				show: false
			},
			axisLabel: {
				textStyle: {
					color: '#fff',
					fontSize: '12'
				}
			},
			splitLine: {// 网格竖轴线
				show:false,
				lineStyle: {
					color: "rgba(255,255,255,.1)",
				}
			}
		
		},
	    xAxis : {
	    	 type : 'category',
	    	 data:shebeiNum[0],
	    	 //data : ['本月负荷','本日负荷','实时负荷'],
				axisLabel: {
					inside: false,
					textStyle: {
						color: '#fff',
						fontSize: '12'
					},
					interval: 0,
					rotate: "40"
				},
				axisTick: {
					show: false
				},
				axisLine: {
					show: true,
					lineStyle: {//纵坐标轴
						color: "#0258f0",
						width: 1,
						type: "solid"
					}
				},
				splitLine: {// 网格横轴线
					show: false,
					lineStyle: {
						color: "rgba(255,255,255,.1)",
					}
				}
			
		},
		series:series,
	    /*series : [
	        {
	            name:'威默电气站点4',
	            type:'bar',
	            barCategoryGap: '60%',
	            stack: '广告',
	            data:[320, 332, 301],
	            itemStyle: {
					normal: {
						color: function(params) {
							// build a color map as your need.
							var colorList = [
								'#0FEB8B'
							];
							return colorList[params.dataIndex]
						},
						barBorderRadius: 2,
					}
				},
	        },
	        {
	            name:'威默电气站点3',
	            type:'bar',
	            stack: '广告',
	            data:[120, 0, 101],
	            itemStyle: {
					normal: {
						color: function(params) {
							// build a color map as your need.
							var colorList = [
								'#DE67F4'
							];
							return colorList[params.dataIndex]
						},
						barBorderRadius: 2,
					}
				},
	        },
	        {
	            name:'威默电气站点2',
	            type:'bar',
	            stack: '广告',
	            data:[220, 182, 0],
	            itemStyle: {
					normal: {
						color: function(params) {
							// build a color map as your need.
							var colorList = [
								 '#21E0DA'
							];
							return colorList[params.dataIndex]
						},
						barBorderRadius: 2,
					}
				},
	        },
	        {
	            name:'威默电气',
	            type:'bar',
	            stack: '广告',
	            data:[0, 232, 201],
	            itemStyle: {
					normal: {
						color: function(params) {
							// build a color map as your need.
							var colorList = [
								 '#448DFE',
							];
							return colorList[params.dataIndex]
						},
						barBorderRadius: 2,
					}
				},
	        }
	    ]*/
	};
	thisTimeLoadChart.setOption(fhrl_option);
	$(document).ready(function() {
		thisTimeLoadChart.resize();
	});
	window.addEventListener("resize", function() {
		thisTimeLoadChart.resize();
	});

}
// 设备分类 结束

// 值班人员
// onlineFunc();
function onlineFunc(unitid){
	// unitid 是站点ID
	// var url="/bigtongji/getRotaList?unitid=000000000001";
	var url="/bigtongji/getRotaList?unitid="+unitid;
	var defer = $.Deferred();
	 $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     //async: false,				   
	     success: function(data){
	    	 defer.resolve(data);
                //alert(data);
               console.log(data);
               var dataObj=eval("("+data+")");// 转换为json对象
               // alert(dataObj);
               // alert(dataObj);
               if(dataObj.rows.length>0){
           		 $("#onlineNotice").html('');
           		 for (var i = 0; i < dataObj.rows.length; i++) {
                		var cid= dataObj.rows[i].cid;
                		var name= dataObj.rows[i].rname;
                		var phone= dataObj.rows[i].phoneCode;
                		//alert(cid);
                		//alert("cid="+cid+"name="+name+"phone="+phone);
               		 $("#onlineNotice").append('<li><span>👨‍⚖️&nbsp;&nbsp;<span id="onlineName1">'+name+'</span>&nbsp;电话：</span><span>'+phone+'</span></li>');
                	  }
           	  }
           	 if(dataObj.rows.length==0){
           		$("#onlineNotice").html(''); 
           	 }
           	yn_online = 1;
	     }
	 });
	 return defer.promise();
}

// 下载资料开始
// 弹框显示隐藏
$('body').click(function(e) {
	  var target = $(e.target);
	  // 如果#overlay或者#btn下面还有子元素，可使用
	  // !target.is('#btn *') && !target.is('#overlay *')
	  if(!target.is('#loadBtn') && !target.is('#downLoad ')) {
	    if ( $('#downLoad').is(':visible') ) { 
	      $('#downLoad').hide();                          
	    }
	  }
	  if(target.is('#loadBtn')) {
	    if ( !$('#downLoad').is(':visible') ) { 
	      $('#downLoad').show();                          
	    }
	  }
});

//
function funDownload(did){
	// window.location.href ="/pmDoc/download?did="+did;
	
	var $eleForm = $('<form method="get" target="iframe"><input name="did" type="hidden" id="did" value="'+did+'"></form>');

    $eleForm.attr("action", "/pmDoc/download?did="+did);

    $(document.body).append($eleForm);

    // 提交表单，实现下载
    $eleForm.submit();
	
}
// 上传列表
// upLoadFunc();
function upLoadFunc(zid){
	// unitid，站点id
	var url="/bigtongji/getList?unitid="+zid;
	// alert('zid='+zid);
	var defer = $.Deferred();
	 $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     //async: false,				   
	     success: function(data){
	    	 defer.resolve(data);
               // alert(data);
               console.log(data);
               var dataObj=eval("("+data+")");// 转换为json对象
               // alert(dataObj);
               // alert(dataObj.rows);
         	   if(dataObj.rows && dataObj.rows != ''){
         		  for (var i = 0; i < dataObj.rows.length; i++) {
             		  // id
             		var did= dataObj.rows[i].did;
             		  // 名字
             		 dname= dataObj.rows[i].dname;
             		  // 文件
             		var docpath= dataObj.rows[i].docpath;
             		  // 备注
             		var dremark= dataObj.rows[i].dremark;
             		// alert(cid);
             		
             		// ========数据绑定<li ><a id="">啊飒飒</a></li>
             		$("#downLoad ul").append("<li class='li' id="+did+">"+dname+"</li>")
             	  }
         	   }if(!dataObj.rows || dataObj.rows == ''){
         		  $("#downLoad ul").html("");
         	   }
         	  
         	// 点击事件处理
         		var oLi = $("#downLoad ul li.li");
         		for(var i=0;i<oLi.length;i++){
         			oLi[i].onclick=function(){
         				var getDid = $(this).attr("id");
         				// alert("getDid="+getDid)
         				funDownload(getDid);
         				
         			}
         		}
	     }
	 });
	 return defer.promise();
}

//返回上一级跳转逻辑处理
function bachFunc(){
	var urlsStr = localStorage.getItem("urls");
	var ss = JSON.parse(urlsStr);
    console.log(ss.yiji);
    if(ss.erji != undefined && ss.erji !=''){
    	//alert(ss.erji);
	    location.href = './intlgMonitor.html'
    }if(ss.yiji != undefined && ss.yiji !=''){
    	//alert(ss.yiji);
	    //location.href = './pro_Home.html'
    }else{  
    	//alert(222)
    }
}

//得到第三级运行天数
//safeDays();
function safeDays(userid,unitid){
    //参数userid用户id,unitid单位id
    //var url="/bigscrenn/getRunDay2?userid=0100000000000004&unitid=010000000000";
	var url="/bigscrenn/getRunDay2?userid="+userid+"&unitid="+unitid;
	var defer = $.Deferred();
	 $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     //async: false,				   
	     success: function(data){
	    	 defer.resolve(data);
            //alert("安全运行天数 = "+data);
            $("#safeDay").text(data); 
            yn_anquan = 1;
	     }
     });
	 return defer.promise();
}

//点击详情开始
function openLayerFunc(id){
	//alert("fhrl=:"+id);
	function sss(title,area,id){
		
			setSessionfunc('','',id,'');//点击详情进入弹框要用到
		
			layer.open({
				type: 2,
				title: true,
				//title:'实时负荷',
				title:title,
				center:"center",
				closeBtn: 1,
				area: ['1020px', '500px'],
				//area: area,
				shadeClose: true,
				skin:"myskin",
				scrollbar:false,
				content: 'tanKuang.html',
				//content: '的发射点犯得上反对'
			});
			//layer 弹框标题、关闭x样式
			$('.myskin').css({
				'background':'#07256b'
			})
			$(".myskin a.layui-layer-ico").text('×').css({
				'color':'#fff',
				'fontSize':'2rem',
				'margin-top': '-15px',
				'background':'none'
			});
			
			$(".layui-layer-title").css({'color':'#fff',});
		
	}
	// 告警信息开始
	var tHeight = 0;
	var windowH = $(window).height();     //浏览器时下窗口可视区域高度
	var dataLength = localStorage.getItem("upDataNum");
	var gjDataLength = localStorage.getItem("gjDataNum");
	
	//-----
	var area = [];
	var title = '';
	
	if(id == "fhrl"){//当点击实时告警推送的详情时的操作
		setSessionfunc('','',id,'');
		if(dataLength && dataLength > 0){
			tHeight = dataLength*37+105;
			//alert("tHeight="+tHeight);
			if(tHeight>windowH){
				tHeight=windowH-400;
			}
		}else{
			tHeight = 138;
		}
		area = ['1020px',tHeight.toString()+'px'];
		sss("实时负荷",area,id);
		
	}
	if(id == "specHomeGJXX"){//当点击实时告警推送的详情时的操作
		setSessionfunc('','',id,'');
		if(gjDataLength && gjDataLength > 0){
			tHeight = gjDataLength*37+105;
			//alert("tHeight="+tHeight);
			if(tHeight>windowH){
				tHeight=windowH-400;
			}
		}else{
			tHeight = 138;
		}
		area = ['1020px',tHeight.toString()+'px'];
		
		ifFunc('告警信息',area,id);
	}
	
	function ifFunc(title,area,ID){
		layer.open({
			type: 2,
			title: false,
			//title:'实时告警详情',
			title:title,
			center:"center",
			closeBtn: 1,
			area: ['1010px', '500px'],
			resize:false,//是否允许拉伸
			//area: area,
			shadeClose: true,
			skin:"myskin",
			scrollbar:false,
			content: 'tanKuang.html'
		});
		//layer 弹框标题、关闭x样式
		$('.myskin').css({
			'background':'#07256b'
		})
		$(".myskin a.layui-layer-ico").text('×').css({
			'color':'#fff',
			'fontSize':'2rem',
			'margin-top': '-15px',
			'background':'none'
		});
		
		$(".layui-layer-title").css({'color':'#fff',});
	}
	// 告警信息结束
}

//判断告警信息弹框的事件类型 设置行颜色
function setTrColrFunc(){
	var trNum = $(".gaojingUl li");
	//alert($(".gaojingUl li").eq(1).find('p').find('span').text());
	
	for(var k=0;k<trNum.length;k++){
		var tdStr1 = $(".gaojingUl li").eq(k).find('p').find('span').text();
		if(tdStr1.indexOf("报警事件") >= 0 ) {
		    $(".gaojingUl li").eq(k).find('a').css('color','orange')
		}if(tdStr1.indexOf("跳闸事件") >= 0 ) {
		    $(".gaojingUl li").eq(k).find('a').css('color','red')
		}if(tdStr1.indexOf("一般事件") >= 0 ) { 
		    $(".gaojingUl li").eq(k).find('a').css('color','#0feb8b')
		}
	}
}

setTimeout(function(){
	//alert("danweiID= "+danweiID+" userid = "+userid);
	if(yn_anquan == 0){
		safeDays(userid,danweiID);
	}
	if(yn_jkzs == 0){
		jiankang(danweiID,userid)
	}
	if(yn_sbfl == 0){
		shebeiFunc(danweiID,userid);
	}
	if(yn_bynhzb == 0){
		haonengZBFunc(danweiID,userid)
	}
	if(yn_bynhb == 0){
		monthNengHao(danweiID,userid)
	}
	if(yn_fhrl == 0){
		resetFuheFunc(danweiID,userid);
	}
	if(yn_glys == 0){
		gonglvys(danweiID,userid)
	}
	if(yn_gjxx == 0){
		yunxingWeiHu(danweiID)
	}
	if(yn_gjtj == 0){
		gaojing(danweiID,userid);
	}
	if(yn_online == 0){
		onlineFunc(danweiID)
	}
	
},5000)